package org.happycomp.radio.downloader;

import java.io.File;
import java.io.IOException;
import java.util.concurrent.locks.Lock;

import org.happycomp.radio.Playlist;
import org.happycomp.radio.Station;
import org.happycomp.radio.StopDownloadCondition;
import org.happycomp.radio.StoreStateException;
import org.happycomp.radio.downloader.impl.IvalidPlaylistContentException;

/**
 * Trida ridi ukladani streamu na disk
 * @author pavels
 */
public interface Downloader {
	
	/**
	 * Synchronizacni zamek
	 * @return
	 */
	public Lock getDownladerLock();
	
	/**
	 * Vraci playlist stanice
	 * @param st Stanice
	 * @return
	 * @throws IOException
	 * @throws IvalidPlaylistContentException
	 */
	public Playlist getPlayList(Station st) throws IOException, IvalidPlaylistContentException;

	/**
	 * Vlastni metoda pro stahovani
	 * @param playlist Playlist stanice
	 * @param title Titulek pro nahravani
	 * @param folder Adresar pro ukladani 
	 * @param condition Podminka ukonceni nahravani
	 * @param uuid Unikantni identifikator
	 * @return 
	 * @throws IOException IO Chyba 
	 * @throws StoreStateException Chyba pri ukladani stavu
	 */
	public  DownloadingItem download(Playlist playlist,String title, File folder, StopDownloadCondition condition, String uuid) throws IOException, StoreStateException;
	
	/**
	 * Vraci vsechny download polozky
	 * @return
	 */
	public DownloadingItem[] getDownloadingItems();

	/**
	 * Nastavi nove download polozky
	 * @param items
	 */
	public void setDownloadingItems(DownloadingItem[] items);
	
	//TODO: smazat
	public void removeDownloadingItem(DownloadingItem item);
}
